/**
 * 
 */
package homework5;

import java.util.LinkedList;

import tester.Tester;

/**
 * @author Nican
 * 
 */
public class Main {

	Graph map = new Graph();
	Node Boston = map.newCity("Boston");
	Node Worcester = map.newCity("Worcester");
	Node Hartford = map.newCity("Hartford");
	Node Chicago = map.newCity("Chicago");
	Node Denver = map.newCity("Denver");
	Node Phoenix = map.newCity("Phoenix");
	Node Houston = map.newCity("Houston");
	Node Tulsa = map.newCity("Tulsa");

	public Main() {
		Boston.addNeighbor(Worcester);
		Boston.addNeighbor(Hartford);
		Chicago.addNeighbor(Denver);
		Phoenix.addNeighbor(Houston);
		Houston.addNeighbor(Tulsa);
	}
	
	public void testGraphBDS(Tester t){
		
		LinkedList<LinkedList<String>> subGraphs = map.getNetworks();
		
		for( LinkedList<String> subGraph : subGraphs ){
			
			if( subGraph.contains("Boston") && subGraph.contains("Worcester") && subGraph.contains("Hartford") )
				continue;
			
			if( subGraph.contains("Chicago") && subGraph.contains("Denver") )
				continue;
			
			if( subGraph.contains("Phoenix") && subGraph.contains("Houston") && subGraph.contains("Tulsa") )
				continue;
			
			t.fail("Not all subgraphs found correctly");
			
		}
		
		for( CityPair cityPair : map.newFlights() ){	
			cityPair.node1.addNeighbor( cityPair.node2 );
		}
		
		LinkedList<LinkedList<String>> OnesubGraphs = map.getNetworks();
		
		t.checkExpect(OnesubGraphs.size(), 1, "New Flights did not make one unified graph");
		
	}

	public void testLevenshtein(Tester t) {

		t.checkExpect(new Levenshtein("kitten", "sitting").minValue(), 3);
		t.checkExpect(new Levenshtein("saturday", "sunday").minValue(), 3);

	}

	public static void main(String[] args) {
		Tester.run(new Main());
	}

}
